<template>
  <BasicForm @register="registerForm" />
</template>
<script lang="ts" setup>
import { BasicForm, useForm } from '@apps/antd-admin/src/components/Form/index';
import { formSchema } from '../data/evaluation.data';
import {Api} from '../data/evaluation.api';
//表单配置
const [registerForm, {setProps, resetFields, setFieldsValue, formSubmit}] = useForm({
  rowKey: 'evaluationId',
  saveApi: Api.save,
  updateApi: Api.update,
  labelWidth: 120,
  schemas: formSchema,
  baseColProps: {
    span: 22,
  },
  showActionButtonGroup: false,
});
async function setData(data) {
  await resetFields();
  if (typeof data.record === 'object') {
    await setFieldsValue({
      ...data.record,
    });
  }
}

/**
 * 提交事件
 */
async function handleSubmit(options) {
  await formSubmit(options);
}

/**
 * 暴露给父组件调用的方法
 */
defineExpose({
  setData,
  handleSubmit,
});
</script>
